/**  
* @Title: IBaseService.java
* @Package com.test.service.base
* @Description: TODO 基础service接口
* @author daiji  
* @date 2015-9-6 下午4:03:11
* @version V1.0  
*/
package base.service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import base.entity.Page;

public interface IBaseService {
	
	/**
	 * 
	* @Title: save
	* @Description: TODO添加单个实体对象
	* @param t 
	* @return    
	* @return T    
	* @throws
	 */
	public <T> T save(T t) throws Exception;
	/**
	 * 
	* @Title: saveOrUpdate
	* @Description: TODO 添加或者更新单个实体
	* @param t
	* @return    
	* @return T    
	* @throws
	 */
	public <T> T saveOrUpdate(T t) throws Exception;
	/**
	 * 
	* @Title: save
	* @Description: TODO 保存实体集合
	* @param list
	* @return    
	* @return List<T>    
	* @throws
	 */
	public <T> List<T> save(Collection<T> list) throws Exception;
	/**
	 * 
	* @Title: delete
	* @Description: TODO删除一个实体
	* @param t
	* @return    
	* @return int    
	* @throws
	 */
	public int delete(Object t) throws Exception;
	/**
	 * 
	* @Title: delete
	* @Description: TODO根据ID删除单个实体
	* @param c
	* @param id
	* @return    
	* @return int    
	* @throws
	 */
	@SuppressWarnings("rawtypes")
	public int delete(Class c,Object id) throws Exception;
	/**
	 * 
	* @Title: delete
	* @Description: TODO删除一个集合中所有的实体
	* @param list
	* @return    
	* @return int    
	* @throws
	 */
	@SuppressWarnings("rawtypes")
	public int delete(Collection list) throws Exception;
	/**
	 * 
	* @Title: getById
	* @Description: TODO根据ID查询单个实体，没有查询到这返回Null
	* @param c
	* @param id
	* @return    
	* @return T    
	* @throws
	 */
	public <T> T getById(Class<T> c,Serializable id) throws Exception;
	/**
	 * 
	* @Title: findOne
	* @Description: TODO按条件查询单个对象，如果没查询到这返回Null
	* @param hql
	* @param params
	* @return    
	* @return T    
	* @throws
	 */
	public <T> T findOne(String hql, Object[] params) throws Exception;
	/**
	 * 
	* @Title: getByIdList
	* @Description: TODO根据ID集合查询实体集合
	* @param c
	* @param ids
	* @return    
	* @return List<T>    
	* @throws
	 */
	@SuppressWarnings("rawtypes")
	public<T> List<T> getByIdList(Class<T> c,Collection ids) throws Exception;
	/**
	 * 
	* @Title: get
	* @Description: TODO查询指定类模板的全部实体集合
	* @param c
	* @return    
	* @return List<T>    
	* @throws
	 */
	public <T> List<T> get(Class<T> c);
	/**
	 * 
	* @Title: find
	* @Description: TODO按条件查询实体集合
	* @param hql
	* @param param
	* @return    
	* @return List<T>    
	* @throws
	 */
	public <T> List<T> find(String hql, Object[] params) throws Exception;
	/**
	 * 
	* @Title: find
	* @Description: TODO按条件分页查询实体集合
	* @param hql
	* @param params
	* @param pageNo
	* @param pageSize
	* @return    
	* @return Page<T>    
	* @throws
	 */
	public<T> Page<T> find(String hql, Object[] params, int pageNo, int pageSize) throws Exception;
	/**
	 * 
	* @Title: countHql
	* @Description: TODO 统计满足条件的数据数量 
	* @param hql
	* @param params
	* @return    
	* @return long    
	* @throws
	 */
	public long countHql(String hql, Object[] params) throws Exception;
	/**
	 * 
	* @Title: executeHql
	* @Description: TODO执行HQL语句
	* @param hql
	* @param param
	* @return    
	* @return long    
	* @throws
	 */
	public int executeHql(String hql, Object[] params) throws Exception;
	/**
	 * 
	* @Title: findByCriteria
	* @Description: TODO 使用hibernate的DetachedCriteria进行查询
	* @param criteria
	* @return    
	* @return List<T>    
	* @throws
	 */
	public<T> List<T> findByCriteria(DetachedCriteria criteria)throws Exception;
	/**
	 * 
	* @Title: findByCriteria
	* @Description: TODO使用hibernate的DetachedCriteria进行分页查询
	* @param criteria
	* @param pageNo
	* @param pageSize
	* @return
	* @throws Exception    
	* @return Page<T>    
	* @throws
	 */
	public<T> Page<T> findByCriteria(DetachedCriteria criteria, Integer pageNo, Integer pageSize)throws Exception;
}
